﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WeChatCore;
using WeChatCore.Common;
using WinInterop = System.Windows.Interop;

namespace WindowsWeChat
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : UserControl
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = ViewModelLocator.Intance.MainVM;

            //CommonMethodCallBackHandlers.ReceivedMsgAnalyseMsgCompleted += CommonMethodCallBackHandlers_ReceivedMsgAnalyseMsgCompleted;
            //new Task(() =>
            //{
            //    WeiChat.InitWeiChatRobot();
            //}).Start();
        }

        private void CommonMethodCallBackHandlers_ReceivedMsgAnalyseMsgCompleted(WeChatCore.Entity.MsgEntity obj)
        {
            Console.WriteLine("hhhhhhhhhhhhhhhhhhhh-" + obj.MsgContent);
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ViewModelLocator.Intance.MainVM.InitData();
            ViewModelLocator.Intance.MainVM.Rtb = RichTextBoxMsg;
        }

        int PrevTimeStamp = 0;
        private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (e.Timestamp - PrevTimeStamp <= 250)
            {
                e.Handled = true;
                return;
            }
            PrevTimeStamp = e.Timestamp;
            if (e.Delta > 0)
            {
                Console.WriteLine("正在向上滚动滑轮");
                //ViewModelLocator.Intance.MainVM.SelectNextPage(1);
            }
            else
            {
                Console.WriteLine("正在向下滚动滑轮");
                //  ViewModelLocator.Intance.MainVM.SelectNextPage(-1);
            }
            e.Handled = true;
        }
        void ScrollDown()
        {
            //s.ScrollToEnd();
        }
        private void BtnClose_Click(object sender, RoutedEventArgs e)
        {
            ViewModelLocator.Intance.MainVM.SaveMsg();
            //this.Close();
        }
    }
}
